<?php
// +----------------------------
// | Created by PhpStorm
// +----------------------------
// | Author: YnnSon
// +----------------------------
namespace app\api\model;

/**
 * 活动
 * Class Activity
 * @package app\api\model
 */
class Activity extends BaseModel
{
    /**
     * @Desc 定义全局的前置查询范围
     *
     * @param $query
     */
    protected function base($query)
    {
        $query->where('is_use', '=', 1)->where('is_delete', '=', 0);
    }

    /**
     * @Desc 获取活动ID
     * @return bool|float|mixed|string|null
     */
    public static function getActivityId()
    {
        $time = time();
        return (new self)->where('opentime', '<', $time)->where('closetime', '>', $time)->value('id');
    }
}